package com.doit.mr.day04.json;

import com.alibaba.fastjson.JSON;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;

/**
 * @DATE 2021/12/8/21:03
 * @Author MDK
 * @Version 2021.2.2
 **/
public class JsonDemo {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new FileReader("D:\\mrdata\\movie\\input\\rating.json"));
        List<Movie> list = new ArrayList<>();
        String line = null;
        while ((line = br.readLine())!= null){
            try {
                // System.out.println(line);
                //将本地数据转化成JavaBean并封装在集合中  注意解析异常
                Movie movie = JSON.parseObject(line, Movie.class);
                System.out.println(movie);
                list.add(movie);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.out.println(list.size());
    }
}
